home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / doors / global / ratios.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  4.7 KB  |  177 lines

  1.  
  2. #include <exec/exec.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include "XIM:doorheader.h"
  6. #include "XIM:glue.h"
  7.  
  8. struct User {
  9.  char    Name[31],Pass[9],Location[30],PhoneNumber[13];
  10.  USHORT  Slot_Number;
  11.  USHORT  Sec_Status,
  12.      Sec_Board,                   /* File or Byte Ratio */
  13.      Sec_Library,                 /* Ratio              */
  14.      Sec_Bulletin,                /* Computer Type      */
  15.      Messages_Posted;
  16.  /* Note ConfYM = the last msg you actually read, ConfRead is the same ?? */
  17.  ULONG   NewSinceDate, ConfRead1, ConfRead2, ConfRead3, ConfRead4,
  18.          ConfRead5;
  19.  UWORD   XferProtocol, Filler2;
  20.  UWORD   Lcfiles,BadFiles; 
  21.  ULONG   AccountDate;
  22.  UWORD   ScreenType, Filler1;
  23.  char    Conference_Access[10];
  24.  USHORT  Uploads, Downloads, ConfRJoin, Times_Called;
  25.  long    Time_Last_On, Time_Used, Time_Limit, Time_Total;
  26.  ULONG   Bytes_Download, Bytes_Upload, Daily_Bytes_Limit, Daily_Bytes_Dld;
  27.  char    Expert;
  28.  ULONG   ConfYM1, ConfYM2, ConfYM3, ConfYM4, ConfYM5, ConfYM6, ConfYM7,
  29.          ConfYM8, ConfYM9;
  30.  long    BeginLogCall;
  31.  UBYTE   Protocol, UUCPA, LineLength, New_User;
  32.  };
  33. struct UserKeys {                 /* changes to UserKeys (RTS) */
  34.  char    UserName[31];
  35.  long    Number;
  36.  UBYTE   New_User;
  37.  UWORD   UPcps;              /* highest upload cps rate */
  38.  UWORD   DNcps;              /* highest dnload cps rate */
  39.  UWORD   Userflags;          /*                         */
  40.  UWORD   baud_rate;          /* last online baud rate   */
  41.  char    Pad[9];             /* ?? should be 15         */
  42. };
  43. struct ConfBase
  44. {
  45.   char Handle[31];
  46.   ULONG NewSinceDate, ConfRead,ConfYM;
  47.   ULONG Bytes_Download,Bytes_Upload;
  48.   ULONG Daily_Bytes_Limit,Daily_Bytes_Dld;
  49.   USHORT Upload,Downloads,RatioType,Ratio,Messages_Posted;
  50.   UWORD Access;
  51.   UWORD Active;
  52. };
  53. struct User U;
  54. struct UserKeys UK;
  55. struct ConfBase CB;
  56. void ShowIntro(void);
  57. char VaultCfg[200];
  58. char bbsroot[200];
  59. ULONG ShowValue(ULONG Value);
  60. FILE *CreateDataBase(char *s);
  61. void end(void);
  62. void LastCommand(void);
  63. char path[200];
  64. #define sm sendmessage
  65. #define gu getuserstring
  66. #define pm prompt
  67. #define hk hotkey
  68. #define pu putuserstring
  69. main(int argc,char *argv[])
  70. {
  71.   FILE *fi,*fo;
  72.   register int i;
  73.   int num;
  74.   ULONG Value;
  75.   USHORT ratio;
  76.   USHORT ratiotype;
  77.   ULONG bytelimit;
  78.   char image[100];
  79.   if(argc!=2)
  80.   {
  81.     printf("\n");
  82.     printf("RATIOS version 1.0 , written by Joseph Hodge\n");
  83.     printf("This is a product of the /X Developement Team - The Silent Achievers\n");
  84.     printf("This is a (XIM) for AmiExpress 3.0+\n");
  85.     printf("\n");
  86.     exit(0);
  87.   }
  88.   Register(argv[1][0]-'0');
  89.   gu(bbsroot,BB_CONFLOCAL);
  90.   strcat(bbsroot,"Conf.DB");
  91.   strcpy(path,bbsroot);
  92.   strcat(path,".old");
  93.   ShowIntro();
  94.   sm("",1);
  95.   pm("Enter Conference Ratio Type (0=Byte, 1=File/Byte, 2=File>: ",image,3);
  96.   switch(image[0])
  97.   {
  98.     case '0': ratiotype=0; break;
  99.     case '1': ratiotype=1; break;
  100.     case '2': ratiotype=2; break;
  101.     default:
  102.      sm("",1);
  103.      sm("Invalid Option.",1);
  104.      sm("",1);
  105.      ShutDown();
  106.      end();
  107.   }
  108.   pm("Enter Ratio >: ",image,4);
  109.   ratio=atoi(image);
  110.   pm("Enter Daily Download Byte Limit >: ",image,15);
  111.   bytelimit=(ULONG)atol(image);
  112.   sm("",1);
  113.   DeleteFile(path);
  114.   Rename(bbsroot,path);
  115.   i=0;
  116.   sm("Changing Conference Ratios & ByteLimit for ALL accounts.Please Standby.",1);
  117.   fi=fopen(path,"rb");
  118.   if(fi==NULL)
  119.   {
  120.     sm("",1);
  121.     sm("Error Changing Data. Cannot Open Conf.DB.old",1);
  122.     sm("",1);
  123.     ShutDown();
  124.     end();
  125.   }
  126.   fo=fopen(bbsroot,"wb");
  127.   if(fo==NULL)
  128.   {
  129.     sm("",1);
  130.     sm("Error Changing Data. Cannot Open Conf.DVB",1);
  131.     fclose(fi);
  132.     Rename(path,bbsroot);
  133.     ShutDown();
  134.     end();
  135.   }
  136.   while(fread((APTR)&CB,sizeof(struct ConfBase),1,fi)!=NULL)
  137.   {
  138.     CB.Ratio=ratio;
  139.     CB.RatioType=ratiotype;
  140.     CB.Daily_Bytes_Limit=bytelimit;
  141.     i+=1;
  142.     if(i==5) { sm(".",0); i=0; }
  143.     fwrite((APTR)&CB,sizeof(struct ConfBase),1,fo);
  144.   }
  145.   sprintf(image,"%d",ratio);
  146.   pu(image,DT_SECLIBRARY);
  147.   sprintf(image,"%d",ratiotype);
  148.   pu(image,DT_SECBOARD);
  149.   sprintf(image,"%ld",bytelimit);
  150.   pu(image,DT_DAILYBYTELIMIT);
  151.   fclose(fi);
  152.   fclose(fo);
  153.   sm("",1);
  154.   ShutDown();
  155.   end();
  156. }
  157.  
  158.   
  159. void ShowIntro(void)
  160. {
  161.   sm("",1);
  162. sm(" .------------------------------------------------------------------------.",1);
  163. sm(" |            Ami-Express RATIOS Version 1.0 Written by ByteMaster        |",1);
  164. sm(" |                /X Development Team - The Silent Achievers              |",1);
  165. sm(" `------------------------------------------------------------------------'",1);
  166.  sm("",1);
  167. }
  168.  
  169. void LastCommand(void)
  170. {
  171.   sm("",1);
  172.   sm("",1);
  173. }
  174. void end(void)
  175. {
  176.    exit(0);
  177. }